import React , { Component , PropTypes} from 'react';
import { Router, Route, IndexRoute } from 'react-router';
import { createStore, combineReducers, applyMiddleware , compose  } from 'redux';
import { Provider } from 'react-redux';
import  * as user  from './reducers';
import thunk from 'redux-thunk';
import User from './components/user';
import Users from './components/users';
import * as hooks from './hooks';

const reducer = combineReducers(user);

const appm = applyMiddleware(thunk)(createStore);

const store = appm(reducer);

console.log(store);

hooks.bootstrap(store)();

class Root extends Component {

	render() {

		const { history } = this.props;

		return(
			<Provider store={store}>
				
					<Router history={history}>
		                <Route path='/' component={User}/>
		                <Route path='/users' component={Users} onEnter={hooks.getUsers(store)} />
					</Router>
				
			</Provider>
		);
	}
}

Root.propTypes = {
	history: PropTypes.object.isRequired
}


export default Root;

